package fwk;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyViewResolver implements ViewResolver {

	@Override
	public void render(ModelAndView mv, HttpServletRequest req,
			HttpServletResponse res) {
		Map<String, Object> mp = mv.getModel();
		if (mp != null) {
			for (String key : mp.keySet()) {
				req.setAttribute(key, mp.get(key));
			}
		}
		try {
			req.getRequestDispatcher(mv.getViewName()).forward(req, res);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
